import React from 'react';
import { Navigate } from 'react-router-dom';
import Login from '@/view/Login/index.tsx';
import MyLayout from '@/Layout/index.tsx';
import lazyLoad from './utils/lazyLoad';

export const routerMap = [
  {
    path: '/',
    element: <Navigate to="/login" />
  },
  {
    path: '/login',
    element: <Login />,
    meta: {
      requiresAuth: false,
      title: '登录页',
      key: 'login'
    }
  },
  {
    element: <MyLayout />,
    meta: {
      title: '常用组件'
    },
    children: [
      {
        path: '/pageOne',
        element: lazyLoad(React.lazy(() => import('@/view/pageOne/index'))),
        meta: {
          requiresAuth: false,
          title: '页面一',
          key: 'pageone',
          icon: 'AppstoreOutlined'
        }
      },
      {
        path: '/pageTwo',
        element: lazyLoad(React.lazy(() => import('@/view/pageTwo/index'))),
        meta: {
          requiresAuth: false,
          title: '页面二',
          key: 'pagetwo',
          icon: 'ContainerOutlined'
        }
      },
      {
        path: '/pageThree',
        element: lazyLoad(React.lazy(() => import('@/view/pageThree/index'))),
        meta: {
          requiresAuth: false,
          title: '页面三',
          key: 'pagethree',
          icon: 'DesktopOutlined'
        }
      },
      {
        path: '/groupOnePageOne',
        element: lazyLoad(React.lazy(() => import('@/view/groupOne/groupOnePageOne'))),
        meta: {
          requiresAuth: false,
          title: '多页面一',
          key: 'groupOnePageOne'
        }
      },
      {
        path: '/groupOnePageTwo',
        element: lazyLoad(React.lazy(() => import('@/view/groupOne/groupOnePageTwo'))),
        meta: {
          requiresAuth: false,
          title: '多页面二',
          key: 'groupOnePageTwo'
        }
      },
      {
        path: '/groupTwoPageOne',
        element: lazyLoad(React.lazy(() => import('@/view/groupTwo/groupTwoPageOne'))),
        meta: {
          requiresAuth: false,
          title: '多页面三',
          key: 'groupTwoPageOne'
        }
      },
      {
        path: '/groupTwoPageTwo',
        element: lazyLoad(React.lazy(() => import('@/view/groupTwo/groupTwoPageTwo'))),
        meta: {
          requiresAuth: false,
          title: '多页面四',
          key: 'groupTwoPageTwo'
        }
      },
      {
        path: '/miniGroupOne',
        element: lazyLoad(React.lazy(() => import('@/view/groupTwo/minGroup/miniGroupOne'))),
        meta: {
          requiresAuth: false,
          title: '小页面',
          key: 'miniGroupOne'
        }
      }
    ]
  },
  {
    path: '*',
    element: <Navigate to="/pageOne" />
  }
];
